// 2025/3/2
// https://leetcode.cn/problems/container-with-most-water/description/?envType=study-plan-v2&envId=top-100-liked
// 盛水最多的容器

class Solution {
    public:
        int calculate(vector<int>& height, int left, int right)
        {
            return (right - left) * min(height[left], height[right]);
        }
    
        int maxArea(vector<int>& height) {
            int left = 0, right = height.size() - 1;
            int ans = calculate(height, left, right);
            while(left < right)
            {
                if(height[left] < height[right])
                    left++;
                else
                    right--;
    
                ans = max(ans, calculate(height, left, right));
            }
            return ans;
        }
    };